<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Home_model extends MY_Model
{

    private $module = 'home';
    private $table = 'news';

    function getSetting($slug = '')
    {
        $this->db->select('*');
        if ($slug != '') {
            $this->db->where('slug', $slug);
            $this->db->limit(1);
        }
        $query = $this->db->get('admin_nqt_settings');
        if ($query->result()) {
            $data = $query->result();
            if (!$slug) {
                $retval = array();
                foreach ($data as $key => $value) {
                    $retval[$value->slug] = $value->content;
                }
            } else
                $retval = $data;
            return $retval;
        } else {
            return false;
        }
    }

    function getListNewBook()
    {
        $this->db->select('b.*, c.name,c.slug as slug_c,u.username');
        $this->db->from('cli_books b, cli_category c, admin_nqt_users u');
        $this->db->where('c.id = b.category_id');
        $this->db->where('u.id = b.author_id');
        $this->db->limit(20);
        $this->db->order_by('id', 'DESC');
        $query = $this->db->get();
        if ($query->result()) {
            return $query->result();
        }
    }
}

?>